import { http } from "@/utils/http";
import type { Order, OrderStatsItem } from "types/order";
import type { PaginationResponse } from "types/flower";

export const getOrderPagination = (data: object) => {
  return http.request<PaginationResponse<Order>>("post", "/order/pagination", {
    data
  });
};

export const getOrderStats = () => {
  return http.request<OrderStatsItem[]>("get", "/order/stats");
};

export const getOrderDetail = (id: number) => {
  return http.request<Order>("get", "/order/detail/" + id);
};

export const deliveryOrder = (data: {
  order_id: number;
  delivery_person_id: number;
}) => {
  return http.request("patch", "/order/delivery", { data });
};

export const closeOrder = (id: number) => {
  return http.request("patch", "/order/close/" + id);
};

export const refundOrder = (id: number) => {
  return http.request("patch", "/order/refund/" + id);
};

export const completeOrder = (id: number) => {
  return http.request("patch", "/order/complete/" + id);
};
